package com.cqemme.activitiservice.controller;

import com.alibaba.fastjson.JSONObject;
import com.cqemme.activitiservice.feign.UserServiceFeign;
import com.cqemme.comm.po.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author nejery
 */
@RestController
@RequestMapping("/user")
@Slf4j
@Api(tags = "用户服务操作接口")
public class UserServiceController {

    @Resource
    private UserServiceFeign userService;

    /**
     * 获取某个组织内的所有人员
     *
     * @param json
     */
    @ApiOperation(value = "根据角色得到一堆人员（node内部调用）", notes = "daibin")
    @RequestMapping(value = "/getRolesUser", method = RequestMethod.POST)
    @ResponseBody
    public Result sosAlarm(@RequestBody String json) {
        Map<String, Object> reqMap = JSONObject.parseObject(json, Map.class);
        Map<String, Object> map = JSONObject.parseObject(json, Map.class);
        map.put("orgId",Integer.parseInt(reqMap.get("orgId").toString()));
        map.put("roleList",JSONObject.parseObject(reqMap.get("roleList").toString(),List.class));
        return userService.getRolesUser(map);
    }

}
